package com.ap.core.validation.message.rules;

import com.ap.core.cxf.jaxb.paymentdetails.TransactionStatusCode;
import com.ap.core.cxf.jaxb.paymentdetails.TxnStatusType;
import com.ap.core.message.managepayment.info.ConfirmPaymentRequestMessageInfo;
import com.ap.core.validation.message.info.MessageValidationInfo;
import com.ap.core.validation.message.info.OriginalInfo;
import com.ap.core.validation.rules.AbstractValidationRule;

/**
 * User:Rohit.Dixit
 *  if <TxnStatus>  is 'AUTHORISED' then <TransactionStatusCode> must be A_00, otherwise it must not
 */
public class IF0011Rule extends AbstractValidationRule<MessageValidationInfo<ConfirmPaymentRequestMessageInfo, OriginalInfo>> {

	@Override
	public boolean validate(
			MessageValidationInfo<ConfirmPaymentRequestMessageInfo, OriginalInfo> infoObject) {
		if(infoObject.getBoundObject().getPaymtDetails().getPaymentStatusInfo().getTxnStatus() == TxnStatusType.AUTHORISED){
			return infoObject.getBoundObject().getPaymtDetails().getPaymentStatusInfo().getTxnStatusCode() == TransactionStatusCode.A_00;
		}
		else {
			return  infoObject.getBoundObject().getPaymtDetails().getPaymentStatusInfo().getTxnStatusCode() != TransactionStatusCode.A_00;
		}
	}

}

